package org.example.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;

@Data
@TableName("order_info")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Order {
    public interface save{};
    public interface Update{}
    @TableId("id")
    @NotNull(message = "订单id不能为空",groups = {Update.class})
    @Min(value = 0,message = "商品ID不能小于0")
    private Integer orderId;
    @TableField("user_id")
    @NotNull(message = "用户id不能为空",groups = {Update.class})
    @Min(value = 0,message = "商品ID不能小于0")
    private Integer userId;
    @TableField("goods_id")
    @NotNull(message = "商品id不能为空",groups = {Update.class})
    @Min(value = 0,message = "商品ID不能小于0")
    private Integer goodsId;
    private String transformNumber;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @Null(message = "支付时间必须为空",groups = {save.class,Update.class})
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "pay_time",fill = FieldFill.INSERT)
    private Date payTime;
    private boolean isGet;
    private int status;

    @TableField(exist = false)
    private String userName;
    @TableField(exist = false)
    private String goodsName;
}
